package com.lvyq.myplayer.ui.fragment

import android.content.Intent
import android.os.Bundle
import com.lvyq.myplayer.adapter.MvListAdapter
import com.lvyq.myplayer.base.BaseListAdapter
import com.lvyq.myplayer.base.BaseListFragment
import com.lvyq.myplayer.base.BaseListPresenter
import com.lvyq.myplayer.model.area.MvPagerBean
import com.lvyq.myplayer.model.area.MvPagerBeans
import com.lvyq.myplayer.parcelable.MvPagerBeansData
import com.lvyq.myplayer.presenter.impl.MvListPresenterImpl
import com.lvyq.myplayer.ui.activity.VideoPlayerActivity
import com.lvyq.myplayer.widget.MvItemView

/**
 * 文件描述：MvPagerFragment  Mv界面每个页面的fragment
 * 作者：lvyq
 * 创建时间：2025-02-26
 * 修改时间：2025-02-26
 */
class MvPagerFragment : BaseListFragment<MvPagerBean,MvPagerBeans,MvItemView>() {

    var code=""


    var name :String?  = null
    //使用BaseFragment中的init
    override fun init() {
         code = arguments?.getString("code").toString()
    }

    override fun getSpecialAdapter(): BaseListAdapter<MvPagerBeans, MvItemView> {
        return MvListAdapter()
    }

    override fun getSpecialPresenter(): BaseListPresenter {
        return MvListPresenterImpl(code,this)
    }

    override fun getList(response: MvPagerBean): List<MvPagerBeans> {
      return  response.rows
    }

    override fun initListener() {
        super.initListener()
        //设置条目点击事件监听函数
        adapter.setMyListener {
            //print("it>>>$it")
            //跳转到视频播放界面
            var intent = Intent(context, VideoPlayerActivity::class.java)
            val data = MvPagerBeansData(
                it.id,it.code,it.title,it.singer,it.url,it.img,it.singerImg,it.timer)
            intent.putExtra("data",data)
            startActivity(intent)

        }
    }
}